﻿<UserControl x:Class="TVersiPlay.AppSettings.Panels.SelectedServerPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="Image" x:Key="ServerImage">
            <Setter Property="Source" Value="/TVersiPlay.AppSettings;component/Resources/checkmark.png" />
            <Setter Property="Stretch" Value="UniformToFill" />

            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=IsActive}" Value="True">
                    <Setter Property="Visibility" Value="Hidden" />
                    <Setter Property="Stretch" Value="UniformToFill" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=IsActive}" Value="False">
                    <Setter Property="Visibility" Value="Visible" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <DataTemplate  x:Key="AvailableServerItemTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="25" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Image MaxHeight="25" MaxWidth="25" Style="{StaticResource ServerImage}" />
                <Button Grid.Column="1" HorizontalAlignment="Stretch" Content="{Binding Path=FriendlyName}"/>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <ListBox SelectedIndex="{Binding Path=SelectedServerIndex}" ItemTemplate="{StaticResource AvailableServerItemTemplate}" ItemsSource="{Binding Path=AvailableServers}">

        </ListBox>
    </Grid>
</UserControl>
